package com.flyan.danmuhunter.common.model;

import java.io.Serializable;
import java.util.Objects;

/**
 * (K, V)
 *
 * @author Flyan
 * @version 1.0
 * @date 2022/4/9 15:45
 *
 * @param <K>
 * @param <V>
 */
public final class Pair<K, V>
        implements Serializable {

    private static final long serialVersionUID = 8583943206046672279L;

    private final K k;
    private final V v;

    public Pair(K k, V v) {
        this.k = k;
        this.v = v;
    }

    public K getK() {
        return k;
    }

    public V getV() {
        return v;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Pair<?, ?> pair = (Pair<?, ?>) o;
        return Objects.equals(k, pair.k) && Objects.equals(v, pair.v);
    }

    @Override
    public int hashCode() {
        return Objects.hash(k, v);
    }

    @Override
    public String toString() {
        return "("+ k + ", " + v + ')';
    }

}
